layui.use(['table', 'layer', 'form', 'laydate', 'util'], function () {
    let table = layui.table;
    let layer = layui.layer;
    let form = layui.form;
    let laydate = layui.laydate;
    let util = layui.util;
    let $ = layui.$;

    // 开始时间
    laydate.render({
        elem: "#startTime"
    });
    laydate.render({
        elem: "#endTime"
    })
    /**
     * 渲染数据表格
     */
    table.render({
        elem: "#order"
        , id: 'order'
        , method: 'get'
        , url: '/'
        , page: ({
            layout: ['prev', 'page', 'next', 'count']
            , first: '首页'
            , last: '尾页'
            , curr: 1
            , groups: 6
        })
        , cols: [[
            {title: '订单号', field: 'order_sn', fixed: 'left'}
            , {title: '餐台', field: 'table_name'}
            , {title: '状态', toolbar: "#state"}
            , {title: '金额', field: 'amount'}
            , {title: '创建时间', field: 'add_time'}
            , {title: '操作', toolbar: "#set"}
        ]]
        , limit: 20
        , event: true
    });

    form.on("submit(search)", function (data) {
        table.reload('order', {
            method: "get"
            , where: {
                state: data.field['state']
                , order_sn: data.field['order_sn']
                , table_sn: data.field['table_sn']
                , start_time: data.field['start_time']
                , end_time: data.field['end_time']
            }
            , page: {
                curr: 1
        }
        });
        return false;
    });
});

